package com.edu.exam.enums.grading;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 动作状态枚举
 *
 * @author 系统生成
 * @version 1.0
 * @since 2025-11-10
 */
public enum ActionStatus implements BaseEnum {

    /**
     * 待执行
     */
    PENDING("PENDING", "待执行"),

    /**
     * 执行中
     */
    EXECUTING("EXECUTING", "执行中"),

    /**
     * 已完成
     */
    COMPLETED("COMPLETED", "已完成"),

    /**
     * 已失败
     */
    FAILED("FAILED", "已失败"),

    /**
     * 已取消
     */
    CANCELLED("CANCELLED", "已取消"),

    /**
     * 超时
     */
    TIMEOUT("TIMEOUT", "超时"),

    /**
     * 跳过
     */
    SKIPPED("SKIPPED", "跳过"),

    /**
     * 暂停
     */
    SUSPENDED("SUSPENDED", "暂停");

    private final String code;
    private final String description;

    ActionStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    /**
     * 从代码创建枚举实例
     *
     * @param code 枚举代码
     * @return 对应的枚举实例
     */
    public static ActionStatus fromCode(String code) {
        for (ActionStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown action status code: " + code);
    }

    @Override
    public String toString() {
        return description;
    }
}